<template>
    <!-- 选择框 -->
    <PopList :title="'表面积测量'" :showButton="true" @ok="start" :rightButton="'开始分析'">
        <LabelInput v-model="interpolation" :label="'采样间距'" :unit="'m'" :readonly="true"></LabelInput>
        <LabelInput v-model="offsetHeight" :label="'偏移高度'" :unit="'m'"></LabelInput>
    </PopList>
</template>
<script setup lang="ts">
import { ESSurfaceAreaMeasurement } from "esobjs-xe2-plugin/dist-node/esobjs-xe2-plugin-main";
import { onBeforeUnmount, onMounted, onUnmounted, inject, ref } from "vue";
import { createVueDisposer, toVR } from 'vue-xe2-plugin/dist-node/components/xe2/tools';
import PopList from "../../../components/PopList.vue";
import { XbsjEarthUi } from "../../../scripts/xbsjEarthUi";
import Message from "vue-xe2-plugin/dist-node/components/xe2/utility/Message";
import LabelInput from "../../../components/LabelInput.vue"

const xbsjEarthUi = inject('xbsjEarthUi') as XbsjEarthUi
const d = createVueDisposer(onBeforeUnmount);

const surfaceAreaMeasurement = xbsjEarthUi.createSceneObject("ESSurfaceAreaMeasurement") as ESSurfaceAreaMeasurement;
// 插值距离
let interpolation = toVR<number>(d, [surfaceAreaMeasurement, "interpolation"])
// 偏移高度
let offsetHeight = toVR<number>(d, [surfaceAreaMeasurement, "offsetHeight"])
offsetHeight.value = 1
const emits = defineEmits(['close'])
const start = () => {
    interpolation.value = Number((Math.sqrt(surfaceAreaMeasurement.area / xbsjEarthUi.Interpolation)).toFixed(2))
    surfaceAreaMeasurement.start()
}
const a = ref(false)
onMounted(() => {
    surfaceAreaMeasurement.editing = true
    Message.warning('结束编辑之后请点击开始分析')
    offsetHeight.value = 1
    interpolation.value = 1

})
onBeforeUnmount(() => {
    surfaceAreaMeasurement.editing = false
    xbsjEarthUi.destroySceneObject(surfaceAreaMeasurement)
})
</script>
